#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int x=0,f=1;char C=getchar();
    while(C<'0'||C>'9'){if(C=='-')f=-1;C=getchar();}
    while(C>='0'&&C<='9')x=x*10+(C^48),C=getchar();
    return x*f;
}
inline void write(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>=10)write(x/10);
    putchar(x%10+'0');
}
const int N = 1e5+5;
int n,m,L,V,d[N],v[N],a[N];
struct Fenshu{
    long long p,q;
    Fenshu operator+(const Fenshu &x){
        Fenshu res;
        res.p=p*x.q+q*x.p;
        res.q=q*x.q;
        if(res.q<0)res.p=-res.p,res.q=-res.q;
        long long gcd=__gcd(abs(res.p),res.q);
        res.p/=gcd;
        res.q/=gcd;
        return res;
    }
    Fenshu operator*(const Fenshu &x){
        Fenshu res;
        res.p=p*x.p;
        res.q=q*x.q;
        if(res.q<0)res.p=-res.p,res.q=-res.q;
        long long gcd=__gcd(abs(res.p),res.q);
        res.p/=gcd;
        res.q/=gcd;
        return res;
    }
    bool operator<(const Fenshu &x)const{
        return p*x.q<q*x.p;
    }
}p[N],fr[N],to[N];
int ans1,ans2;
struct Node{
    int l,r;
    bool operator<(const Node &x)const{
        if(r==x.r)return l>x.l;
        return r<x.r;
    }
}pr[N];
bool vis[N];
const int inf = 1e6+5;
void My_clear(){
    for(int i=1;i<=ans1;i++){
        pr[i].l=pr[i].r=0;
    }
    ans1=ans2=0;
}
void solve(){
    n=read();m=read();L=read();V=read();
    My_clear();
    for(int i=1;i<=n;i++){
        d[i]=read();
        v[i]=read();
        a[i]=read();
        Fenshu st,ed;
        if(v[i]>V){
            st=(Fenshu){0,1};
            if(a[i]>=0){
                ed=(Fenshu){inf,1};
            }
            else{
                ed=(Fenshu){v[i]-V,1}*(Fenshu){-1,a[i]};
            }
        }
        else{
            ed=(Fenshu){inf,1};
            if(a[i]<=0){
                st=(Fenshu){inf,1};
            }
            else{
                st=(Fenshu){V-v[i],1}*(Fenshu){1,a[i]};
            }
        }
        fr[i]=(Fenshu){d[i],1}+(Fenshu){v[i],1}*st+(Fenshu){1,2}*(Fenshu){a[i],1}*st*st;
        to[i]=(Fenshu){d[i],1}+(Fenshu){v[i],1}*ed+(Fenshu){1,2}*(Fenshu){a[i],1}*ed*ed;
        //printf("%.5f %.5f\n",fr[i],to[i]);
    }
    for(int i=1;i<=m;i++){
        p[i]=(Fenshu){read(),1};
    }
    for(int i=1;i<=n;i++){
        int st;
        if(v[i]>V)st=lower_bound(p+1,p+m+1,fr[i])-p;
        else st=upper_bound(p+1,p+m+1,fr[i])-p;
        int ed=lower_bound(p+1,p+m+1,to[i])-p-1;
        if(st<=ed&&st<=m){
            pr[++ans1]=(Node){st,min(ed,m)};
            //cout<<st<<" "<<ed<<endl;
        }
    }
    sort(pr+1,pr+ans1+1);
    for(int i=1,lst=0;i<=ans1;i++){
        if(pr[i].r==pr[i-1].r)continue;
        if(pr[i].l>lst){
            ans2++;
            lst=pr[i].r;
            //cout<<lst<<" ";
        }
    }//cout<<endl;
    ans2=m-ans2;
    cout<<ans1<<" ";
    cout<<ans2<<endl;
    //cout<<"~~~~~~~~\n";
    //My_clear();
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T=read();
    while(T--){
        solve();
    }
    return 0;
}